(function() {
  'use strict';
  angular.module('chart.directives', []).directive('cambio', function() {    
    return {
        restrict: 'A',
        scope:{'cambio':'=',
              },
        controller: function($scope,$http){
             $http.post('http://localhost/api_tcpro/web/app_dev.php/admin_proyecto/variables_lista',{
                  id_proyecto : 1
                }).success(function(data){
                  $scope.ver = data;
                  console.log(data)
                });
        },
        link: function(scope, elm, attrs) {            
            var data,plot,options;
            scope.$watch('cambio', function(nVal) { elm.val(nVal); });            
            elm.bind('click', function() {
                data = [{                        
                          label: "cambio",
                          data: 12
                        }, {
                          label: "In-Store Sales",
                          data: 30
                        }, {
                          label: "Mail-Order Sales",
                          data: 20
                        }
                      ];
                options = options = {
                              series: {
                                pie: {
                                  show: true
                                }
                              },
                              legend: {
                                show: true
                              },
                              grid: {
                                hoverable: true,
                                clickable: true
                              },
                              colors: ["blue", "red", "pink"],
                              tooltip: true,
                              tooltipOpts: {
                                content: "%p.0%, %s",
                                defaultTheme: false
                              }
                            };
                scope.$apply(function() {
                        return $.plot(elm[0], data,options);
                    });
                //return 
            });
        }
    };        
});
}).call(this);

